package com.yxym.homework;

public class Homework06 {
    public static void main(String[] args) {
        person person = GongChang.getPerson("M");
//        person person1 = GongChang.getPerson("R");
//        person person2 =GongChang.getPerson("W");
        assert person != null;
        person.makePerson();
    }
}

interface person{
    void makePerson();
}
 class Man implements person{
    @Override
    public void makePerson() {
        System.out.println("诞生一个男人");
    }
}
class Woman implements person{

    @Override
    public void makePerson() {
        System.out.println("诞生一个女人");
    }
}

class Robot implements person{

    @Override
    public void makePerson() {
        System.out.println("诞生一个机器人");
    }
}

class GongChang{
    public static person getPerson(String sex){
        if(sex.equalsIgnoreCase("M"))
        {
            return new Man();
        }

        if (sex.equalsIgnoreCase("W")){
            return new Woman();
        }

        if (sex.equalsIgnoreCase("R"))
        {
            return new Robot();
        }else {
            return null;
        }
    }
}
